
$(function(){
	
	//显示更多筛选条件
	$(".more p").on("click",function(){
		var value=$(this).attr("value");
		if(value==="0"){
			var str='收起选项<i class="iconfont icon-arrow-up">';
			$(".fold").slideDown();
			$(this).attr("value","1");
			$(this).html(str);
		}else{
			var str='显示全部选项<i class="iconfont icon-arrow-down">';
			$(".fold").slideUp();
			$(this).attr("value","0");
			$(this).html(str);
		}
	});
	
	/*----------------------------------------------
	 * 删除项目
	 * 1、用户点击项目删除按钮，弹出删除项目提示框
	 * 2、用户确认时该删除项目，并关闭提示框
	 *----------------------------------------------*/
	var project={ id:'' , del:function(fn){fn();} };
	
	//获取项目id，弹出删除项目提示框
	$("#dataList").on("click",".delPro",function(){
		var target=$(this).parents("div.projects-item");
		project.id=target.attr("data-value");
		target.addClass("readyToDel").siblings().removeClass("readyToDel");
		$("#del-project-modal").modal("show");
	});
	
	//确定删除项目
	$("#del-project-modal .confirm").on("click",function(){
		project.del(function(){
			$.ajax({
				type:"get",
				url:"/projects/deletePro",
				data:{'id':project.id},
				dataType:'json',
				success:function(data){
					if(data.status==true){
						$("#dataList .readyToDel").remove();
					}
				}
			});
		});
	});
	
	if($("#totalPages").val()>0){
		pages();
	}
	
	//权限控制
	authorization();
	
	//筛选条件交互
	//$(".condition-filter span,.progress-key,.allItem").click(function(){
	$(".condition-filter span,.left-bar a.btn-block").on("click",function(){
		var id=$(this).parent().attr("id");
		switch(id){
			case "area":
				$('#areaId').val($(this).attr('data-value'));
				$(this).addClass("active").siblings().removeClass("active");
				break;
				
			case "field":
				$('#fieldId').val($(this).attr('data-value'));
				$(this).addClass("active").siblings().removeClass("active");
				break;
				
			case "round":
				$('#roundId').val($(this).attr('data-value'));
				$(this).addClass("active").siblings().removeClass("active");
				break;
				
			case "unit":
				$('#unitId').val($(this).attr('data-value'));
				$(this).addClass("active").siblings().removeClass("active");
				break;
			
			case "dealman":
				$('#dealmanId').val($(this).attr('data-value'));
				$(this).addClass("active").siblings().removeClass("active");
				break;
				
			case "parentItem":
				if($(this).hasClass('allItem')){
					$('#progressId').val(0);
				}else{
					$('#progressId').val($(this).find('.progress-name').data('value'));
				}
				$("#dataType").val(1);
				$(".left-bar a.btn-block").removeClass("active");
				$(this).addClass("active");
				break;
				
			case "ownItem":
				if($(this).hasClass('allItem')){
					$('#progressId').val(0);
				}else{
					$('#progressId').val($(this).find('.progress-name').data('value'));
				}
				$("#dataType").val(0);
				$(".left-bar a.btn-block").removeClass("active");
				$(this).addClass("active");
				break;
				
			default:
				$('#progressId').val($(this).find('.progress-name').data('value'));
				$(this).parents("a.item").addClass("active").siblings().removeClass("active");
				break;
		}
	});
	
	/*
	 * 点击筛选框的时候，进行一步请求
	 */
	$(".condition-filter span,.icon-sousuo-sousuo").on("click",function() {
		ajaxData(1);
	});
	
	//点击左边进度导航栏
	$(".left-bar").on("click","a.btn-block",function(){
		ajaxData(1);
	});

	//回车键搜索
	$(document).on("keydown",function(event){
		var e=event || window.event;
		if(e.keyCode==13){
			ajaxData(1);
		}
	});
	
	/*----------------------------------------------------------
	 * 模态框操作 (modal start)
	 ---------------------------------------------------------*/
	/**点击模态框关闭按钮时**/
	//1、收起选项，取消选项标志类名selected
	//#now-priority-modal，#now-progress-modal下
	$(".modal .close").click(function(){
		var $parent=$(this).parents(".modal").find(".options");
		$parent.hide().find(".options-item").removeClass("selected");
	});

	//2、收起展开选项
	$(".modal .btn-unfold").click(function(){
		$(this).parent().find(".options").slideToggle();
	});
	
	/**当前进度**/
	//改变当前进入框内容
	$('.userProgress_flag').click(function(){
		$('.bg-white div').removeClass('on');
		$(this).addClass('on');
		var $thisProgress = $(this).find('span');
		var str=$thisProgress.text()+"<i class='pull-right iconfont icon-control-arr-copy-copy' style='color:#999;'></i>";
		$('#userProgress_flag_value').html(str);
		$('#userProgress_flag_value').attr('value', $thisProgress.data('value'));
		$('#proId_view').val($(this).data('value'));
	});
	
	//关闭时,收起选项，并删除类名selected
	$("#now-progress-modal .cancel,#now-progress-modal .confirm").click(function(){
		var $modal=$("#now-progress-modal");
		$modal.find(".options").hide();
		$modal.find(".options-item").removeClass("selected");
	});
	
	//选择选项时
	$("#now-progress-modal .options-item").click(function(){
		var value=$(this).attr("value"),
			str=$(this).text()+ "<i class='pull-right iconfont icon-control-arr-copy-copy' style='color:#999;'></i>";
		$(this).addClass("selected").siblings().removeClass("selected");
		$("#now-progress-modal .btn-unfold").attr("value",value).html(str);
	});
	
	//用户确认提交时
	$("#now-progress-modal .confirm").click(function(){
		var progressId = $('#userProgress_flag_value').attr('value');
		var proId = $('#proId_view').val();
		var progressName = $('#userProgress_flag_value').text();
		$.post(
				'/projects/changeProjectProgress',
				{
					'proId' : proId,
					'progressId' : progressId
				},
				function(data){
					if(data.status == true){
						
						//在左边项目栏中，将当前操作进度的项目数量减1
						var oID=$('.bg-white .on span').attr("data-value");
						changeProgressCount(oID,".left-bar .progress-key",-1);
						
						//将修改的进度的项目数量加1
						changeProgressCount(progressId,".left-bar .progress-key",1);

						function changeProgressCount(id,selector,value){
							var el="[data-value='" + id + "']";
							var count=parseInt($(selector).find(el).next("i").text())+value;
							$(selector).find(el).next("i").text(count);
						}
						
						if($(".left-bar .allItem").hasClass("active")){
							$('.bg-white .on span').html(progressName);
						}else{
							$(".bg-white .on").parents(".projects-item").remove();
						};
						window.location.href = "/projects/list";
					}
				},'json'
		);
	});
	
	/**当前跟进人**/
	$('.follow_flag').on('click',function(){
		$('.bg-white div').removeClass('on');
		$(this).addClass('on');
		$("#proId_view_follow").val($(this).attr('data-value'));
		var count = $(this).find('input').length;
		if(count>0){
			var $followView = $('#follow_flag_value');
			$followView.find('small').hide();
			$followView.find('span').remove();
			var html = "";
			$(this).find('input[type="hidden"]').each(function(){
				html += '<span value="'+$(this).val()+'">'+$(this).data('value')+'</span>';
			});
			$followView.find('small').after(html);
		}
	});
	
	//1、关闭模态框时，收起选项,并清空选项
	//点击项目列表按钮
	$(".modal .cancel,.modal .close").click(function(){
		var $modal=$(this).parents(".modal");
		$modal.find(".options").hide();
		$modal.find(".options-item").removeClass("selected");
		$modal.find(".btn-unfold span").remove();
		$modal.find(".btn-unfold small").show();
	});
	
	//点击出现下拉框
	$('#follow_flag_value').click(function(){
		var $thisSpan = $(this).find('span');
		var $boxs = $('#follow_flag_value .options').find('a');
		$thisSpan.each(function(){
			var this1 = this;	    				
			$boxs.each(function(){
				if($(this1).attr('value') == $(this).attr('value')){
					$(this).addClass('selected');
				}
			});
		});
	});
	
	//2、选择选项时
	$("#current-follow-modal .options-item").click(function(){
		var $this=$(this),
			value=$this.attr("value"),
			$unfold=$("#current-follow-modal .btn-unfold");
		if($this.hasClass("selected")){
			var $arr=$unfold.find("span");
			$this.removeClass("selected");
			//移除选项
			$.each($arr, function(i) {
				if($arr.eq(i).attr("value")==value){
					$arr.eq(i).remove();
				}
			});
			//如果没有选项，显示“请选择”文本
			if($arr.length<=1){
				$unfold.find("small").show();
			}
		}else{
			var $span=$("<span></span>"),
				str=$this.text();
			$this.addClass("selected");
			$span.text(str).attr("value",value).attr("title",str);
			$unfold.find("small").hide()
			$unfold.find("i").before($span);
		}
	});
	
	//3、用户提交时
	$("#current-follow-modal .confirm").on('click',function(){
		//1、发送用户修改内容
		//2、收起选项,并清空选项
		var $modal=$("#current-follow-modal");
		$modal.find(".options").hide();
		$modal.find(".btn-unfold small").show();
		$modal.find(".options-item").removeClass("selected");
		
		//跟进人ids
		var ids=new Array();
		$('#follow_flag_value').find('span').each(function(i, obj){
			ids[i] = $(this).attr('value');
		});
		var proId = $('#proId_view_follow').val();
		$.post(
				'/projects/updateFollow',
				{'ids' : ids, 'proId' : proId},
				function(data){
					if(data.status == true){
						var $ProDiv = $('.bg-white .on');
						var follow = data.data.follow;
						var html = '';
						if(follow != ""){
							html += '<span class="btn-follow" data-toggle="modal" data-target="#current-follow-modal">'+follow[0].name+'</span>';
							$.each(follow, function(i){
								html += '<input type="hidden" value="'+follow[i].id+'" data-value="'+follow[i].name+'">';
							});
						}else{
							html += '<span class="btn-follow" data-toggle="modal" data-target="#current-follow-modal">请选择</span>';
						}
						$ProDiv.html('').html(html);
					}
				},'json'
				);	    			
		$modal.find(".btn-unfold span").remove();
	});
	
	/**当前优先级**/
	//改变当前进入框内容
	$('.unit_flag').click(function(){
		$('.bg-white div').removeClass('on');
		$(this).addClass('on');
		var $thisProgress = $(this).find('span');
		var str=$thisProgress.text()+"<i class='pull-right iconfont icon-control-arr-copy-copy' style='color:#999;'></i>";
		$('#unit_flag_value').html(str);
		$('#unit_flag_value').attr('value', $thisProgress.data('value'));
		$('#proId_view_unit').val($(this).data('value'));
	});
	
	//关闭时,收起选项，并删除类名selected
	$("#now-priority-modal .cancel,#now-priority-modal .confirm").click(function(){
		var $modal=$("#now-priority-modal");
		$modal.find(".options").hide();
		$modal.find(".options-item").removeClass("selected");
	});
	
	//选择选项时
	$("#now-priority-modal .options-item").click(function(){
		var value=$(this).attr("value"),
			str=$(this).text()+ "<i class='pull-right iconfont icon-control-arr-copy-copy' style='color:#999;'></i>";
		$(this).addClass("selected").siblings().removeClass("selected");
		$("#now-priority-modal .btn-unfold").attr("value",value).html(str);
	});
	
	//用户确认提交时
	$("#now-priority-modal .confirm").click(function(){
		var unitId = $('#unit_flag_value').attr('value');
		var proId = $('#proId_view_unit').val();
		var unitName = $('#unit_flag_value').text();
		$.post(
				'/projects/changeProjectUnit',
				{
					'proId' : proId,
					'unitId' : unitId
				},
				function(data){
					if(data.status == true){
						$('.bg-white .on span').html(unitName);
					}
				},'json'
		);
	});
});

/**
 * 分頁處理
 */
function pages(){
	var pageNo = $('#pageNo').val();
	var pageSize = $('#pageSize').val();
	var totalCount = $('#totalCount').val();
	var totalPages = $('#totalPages').val();
	
	var displayNo = 0;
	if(totalPages>=5){
		displayNo = 5;
	}else{
		displayNo = totalPages;
	}
	$("#pagination").paginate({
		count: totalPages,
		start : 1,
		display : displayNo,
		border : false,
		// border_color : '#ddd',
		text_color : '#337ab7',
		background_color : 'transparent',
		border_hover_color : 'transparent',
		text_hover_color : '#fff',
		background_hover_color : '#337ab7',
		images : false,
		mouse : 'slide',
		onChange:function(p){
			$('#pageNo').val(p);
			ajaxData(0);
		}
	});

}

/**
 * 異步請求數據
 * type参数在分页时为0
 */
function ajaxData(type){
	if(type==1){
		$('#pageNo').val(1);
	}
	$('#keyWorld').val($("#search").val());
	$.post(
		"/projects/projectData", {
			"areaId": $('#areaId').val(),
			"roundId": $('#roundId').val(),
			"fieldId": $('#fieldId').val(),
			"unitId": $('#unitId').val(),
			"dealmanId": $("#dealmanId").val(),
			"progressId": $('#progressId').val(),
			"keyWorld": $('#keyWorld').val(),
			"userType": $("#dataType").val(),
			"pageNo" : $("#pageNo").val()
		},
		function(data) {
			$('#dataList').empty();
			//异步加载数据
			var html = '';
			$.each(data.data.dataJson, function(i, obj) {
				html += '<div class="projects-item col-sm-12 col-md-6 col-lg-4" data-value=' + obj.id + '>';
				html += '<div class="item-body bg-white clearfix">';
				//如果是机构用户，显示项目删除按钮
				if($("#userType").val()==2){
					html += '<span class="delPro iconfont icon-shanchu2" title="删除项目"></span>';
				}else{
					if(obj.dealman == ""){
						html += '<span class="delPro iconfont icon-shanchu2" title="删除项目"></span>';
					}
				}
				html += "<div class='item clearfix'>"
				html += "<a href='/projects/projectDetail/"+ obj.id + "' target='_blank'>";
				html += "<div class='item-logo pull-left'>";
				//如果有logo图片显示图片，否则显示项目名的首字
				if(obj.logo){
					html += "<img src='" + obj.logo + "'/>";
				}else{
					var firstWord=obj.name.trim().charAt(0);
					html += "<div class='first-word'>" + firstWord + "</div>";
				}
				html += "</div>";
				html += "</a>";
				html += "<a  class='project-item-name pull-left' href='/projects/projectDetail/" + obj.id + "' target='_blank'>" +obj.name;
				if($("#userType").val()==1){
					html += "<span class='principal'><i>负责人："+obj.dealman+"</i></span>";
				}
				html += "</a></div>";
				html += '<div class="row icon-group">';
				html += '<div class="col-xs-4 no-padding text-left"><i class="iconfont icon-diqu"></i>' + obj.areaName + '</div>';
				html += '<div class="col-xs-4 no-padding text-center"><i class="iconfont icon-shuju"></i>' + obj.rounName + '</div>';
				html += '<div class="col-xs-4 no-padding text-right"><i class="iconfont icon-shuju1"></i>' + obj.money + '万</div>';
				html += '</div>';
				html += '</div>';	
				html += '<div class="item-footer" style="padding:0 15px;">';
				html += '<div class="row bg-white" style="padding:15px 0;">';
				html += '<div class="col-xs-6 text-left userProgress_flag" onclick="progressClick(this)" data-value="' + obj.id + '">';

				if(obj.progressId != 0) {
					html += '<span data-value="' + obj.progressId + '" class="btn-progress" data-toggle="modal" data-target="#now-progress-modal">' + obj.progress + '</span>';
				} else {
					html += '<span data-value="0" class="btn-progress" data-toggle="modal" data-target="#now-progress-modal">选择进度</span>';
				}
				html += '</div>';
				html += '<div class="col-xs-6 text-right unit_flag" onclick="unitClick(this)" data-value="' + obj.id + '">';
				if(obj.unitId != 0) {
					html += '<span class="btn-priority" data-toggle="modal" data-target="#now-priority-modal">' + obj.unit + '</span>';
				} else {
					html += '<span data-value="0" class="btn-priority" data-toggle="modal" data-target="#now-priority-modal">选择等级</span>';
				}
				html += '</div>';
				
/*				if(obj.authorization==1){
					if(obj.progressId != 0) {
						html += '<span data-value="' + obj.progressId + '" class="btn-progress" data-toggle="modal" data-target="#now-progress-modal">' + obj.progress + '</span>';
					} else {
						html += '<span data-value="0" class="btn-progress" data-toggle="modal" data-target="#now-progress-modal">请选择</span>';
					}
					html += '</div>';
					html += '<div class="col-xs-4 text-center unit_flag" onclick="unitClick(this)" data-value="' + obj.id + '">';
					if(obj.unitId != 0) {
						html += '<span class="btn-priority" data-toggle="modal" data-target="#now-priority-modal">' + obj.unit + '</span>';
					} else {
						html += '<span data-value="0" class="btn-priority" data-toggle="modal" data-target="#now-priority-modal">请选择</span>';
					}
					html += '</div>';
					if(obj.proType==1){
						html += '<div class="col-xs-4 text-right follow_flag" onclick="followClick(this)" data-value="' + obj.id + '"><span class="btn-follow" data-toggle="modal" data-target="#current-follow-modal">' + obj.followName + '</span>';
					}
				}else{
					if(obj.progressId != 0) {
						html += '<span data-value="' + obj.progressId + '" class="btn-progress" data-toggle="modal" data-target="#no-permission-modal">' + obj.progress + '</span>';
					} else {
						html += '<span data-value="0" class="btn-progress" data-toggle="modal" data-target="#no-permission-modal">请选择</span>';
					}
					html += '</div>';
					html += '<div class="col-xs-4 text-center unit_flag" onclick="unitClick(this)" data-value="' + obj.id + '">';
					if(obj.unitId != 0) {
						html += '<span class="btn-priority" data-toggle="modal" data-target="#no-permission-modal">' + obj.unit + '</span>';
					} else {
						html += '<span data-value="0" class="btn-priority" data-toggle="modal" data-target="#no-permission-modal">请选择</span>';
					}
					html += '</div>';
					if(obj.proType==1){
						html += '<div class="col-xs-4 text-right follow_flag" onclick="followClick(this)" data-value="' + obj.id + '"><span class="btn-follow" data-toggle="modal" data-target="#no-permission-modal">' + obj.followName + '</span>';
					}
				}
				var arr_f = obj.follows;
				$.each(arr_f, function(j) {
					html += '<input type="hidden" value="' + arr_f[j].id + '" data-value="' + arr_f[j].name + '">';
				});*/
				html += '</div>';
				html += '</div>';
				html += '</div>';
				html += '</div> ';
			});

			//处理搜索栏
			var query = data.data.query;
			if(query.userType == 1) {
				/*$('#parentDiv').show();
				$('#ownDiv').hide();

				$('#parentProgress').show();
				$('#ownProgress').hide();*/
				$('#parentProgress').find('a.btn-unfold').attr('id','userProgress_flag_value');
				$('#ownProgress').find('a.btn-unfold').attr('id','');
			} else {
				/*$('#parentDiv').hide();
				$('#ownDiv').show();

				$('#parentProgress').hide();
				$('#ownProgress').show();*/
				$('#ownProgress').find('a.btn-unfold').attr('id','userProgress_flag_value');
				$('#parentProgress').find('a.btn-unfold').attr('id','');
			}
			var olderTotalCount = $('#totalCount').val();
			
			//處理分頁
			$('#pageNo').val(data.data.pageNo);
			$('#pageSize').val(data.data.pageSize);
			$('#totalCount').val(data.data.totalCount);
			$('#totalPages').val(data.data.totalPages);
			$('#dataList').append(html);
			
			//如果html为空,显示无项目
			if($("#totalCount").val()=="0"){
				var str = "<div class='pro-null'>"
						+ "<div>"
						+ "<img src='/resources/src/images/center003.png' />"
						+ "<p>暂无项目</p>"
						+ "</div>"
						+ "</div>";
				$('#dataList').append(str);		
				$("#pagination").hide();
			}else{
				$("#pagination").show();
			}
			
			if(data.data.totalCount!=olderTotalCount){
				pages();
			}

		},"json"
	);
	//$(window).resize();
}

//异步之后修正进度(进度)
function progressClick(_this){
	$('.bg-white div').removeClass('on');
	$(_this).addClass('on');
	$('#proId_view').val($(_this).data('value'));
	$('#userProgress_flag_value').text($(_this).find('span').text());
}

//异步之后修正进度(优先级)
function unitClick(_this){
	$('.bg-white div').removeClass('on');
	$(_this).addClass('on');
	$('#proId_view_unit').val($(_this).data('value'));
	$('#unit_flag_value').text($(_this).find('span').text());
}

//跟进人异步处理
function followClick(_this){
	$('.bg-white div').removeClass('on');
	$(_this).addClass('on');
	$("#proId_view_follow").val($(_this).attr('data-value'));
	var count = $(_this).find('input').length;
	if(count>0){
		var $followView = $('#follow_flag_value');
		$followView.find('small').hide();
		$followView.find('span').remove();
		var html = "";
		$(_this).find('input[type="hidden"]').each(function(){
			html += '<span value="'+$(this).val()+'">'+$(this).data('value')+'</span>';
		});
		$followView.find('small').after(html);
	}

}

/*------------------------
 * 
 * 地区管理
 * 行业管理
 * 
 -------------------------*/

//添加函数
//demo参数为触发的目标元素
function addItem(demo){
	var id,len,arr,flag=false;
	id=demo.attr("data-value");
	console.log(id);
	
	arr=demo.parents(".modal-content").find(".item-name");
	len=arr.length;
	$.each(arr,function(i){
		var value=arr.eq(i).attr("data-value");
		//如果地址id相等，表明地址重复
		if(id===value){
			return flag=true;
		}
	});
	
	if(!flag){
		//将选择的地区添加到下方“已选择”区域
		var $span,html,name;
		name=demo.text();
		
		//在“已选择”区域插入新地区
		$span=$("<span class='pull-left'></span>");
		html="<i class='item-name' data-value="+ id +">" + name+ "</i><i class='iconfont icon-shanchu del'></i>";
		$span.html(html);
		demo.parents(".modal-content").find(".selected").append($span);
	}
}

//搜索地区
$("#search-area").on("keyup",function(){
	var value=$(this).val().trim();
	if(value!=null&&value!=""){
		$.post(
				"/projects/searchArea",
				{"keyWord":value},
				function(data){
					if(data.status==true){
						var html = "";
						$("#select-area").empty();
						var arry = data.data.list;
						$.each(arry, function(i){
							html += '<p class="clearfix"><span class="pull-left" data-value="'+arry[i].id+'">'+arry[i].name+'</span><span class="add-area pull-right"><i class="iconfont icon-icon-xinjian"></i>添加</span>'
						});
						$("#select-area").html(html);
					}
				},"json"
		);
	}
});

//从搜索的地区中添加地区
$("#select-area").on("click",".add-area",function(e){
	var e=e || window.event, that=e.target || e.srcElement;
	addItem($(that).prev());
})

//从热门的地区、行业中添加地区或行业
$("#area-modal .hot-item,#business-modal .hot-item").on("click","span",function(e){
	var e=e || window.event, that=e.target || e.srcElement;
	addItem($(that));
});

//删除已选择的地区,行业
$("#area-modal .selected,#business-modal .selected").on("click",".del",function(e){
	var e=e || window.event, that=e.target || e.srcElement;
	//删除
	$(that).parent().remove();
});

//保存地区
$("#area-modal .confirm").on("click", function(e){
	var arrays = new Array();
	$(this).parent().find("span").find(".item-name").each(function(i){
		arrays[i] =  $(this).data("value");
	});
	$.post(
			"/projects/updataAreas",
			{"arrays":arrays},
			function(data){
				if(data.status){
					location.reload();
				}
			},"json"
	);
});

//保存行业
$("#business-modal .confirm").on("click", function(e){
	var arrays = new Array();
	$(this).parent().find("span").find(".item-name").each(function(i){
		arrays[i] =  $(this).data("value");
	});
	$.post(
			"/projects/updateFields",
			{"arrays":arrays},
			function(data){
				if(data.status){
					location.reload();
				}
			},"json"
	);
});


//js控制前端的权限
function authorization(){

	var userId = $("#userId").val();
	var userType = $("#userType").val();
	$(".follow_flag").each(function(){
		var flag = 0;
		var $this = $(this);
		var count = $this.find('input').length;
		if(count>0){
			$this.find('input').each(function(){
				if($(this).val()==userId){
					flag = 1;
				}
			});
		}
	if(userType==2&&flag==0){
		$this.find('span').attr("data-target","no-permission-modal");
		$this.parent().find('.unit_flag').find('span').attr("data-target","no-permission-modal");
		$this.parent().find('.userProgress_flag').find('span').attr("data-target","no-permission-modal");
	}
	});
} 

function createPro(){
	var divId = $('.left-bar .active').parent().attr('id');
	var type = 0;
	//添加自己项目为1，机构项目为2
	if(divId=="ownItem"){
		type=1;
	}else{
		type=2;
	}
	window.location.href="/projects/addProject?type="+type;
}
